import { createVNode } from 'vue';
import { BasicColumn, FormSchema } from '@/components/Table';
import dayjs from 'dayjs';

export const columns: BasicColumn[] = [
  {
    title: '日志内容',
    dataIndex: 'roleName',
    align: 'left'
  },
  {
    title: '操作状态',
    dataIndex: 'status',
    width: 120
  },
  {
    title: '操作方式',
    dataIndex: 'way',
    width: 120
  },
  {
    title: '操作IP',
    dataIndex: 'roleValue',
    width: 180,
    customRender:({record})=>{
      return createVNode('div',{},[
        createVNode('div',{},'192.168.1.1'),
        createVNode('div',{},'江苏苏州')
      ]);
    }
  },
  {
    title: '操作人',
    dataIndex: 'account',
    width: 200,
  },
  {
    title: '创建时间',
    dataIndex: 'id',
    width: 180,
    sorter: true,
    fixed: 'right',
    customRender: ({record})=>{
      return record.createTime;
    }
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: '[startDate, endDate]',
    label: '日期范围',
    labelWidth: 80,
    component: 'RangePicker',
    colProps: { xs: 24, xl: 12, lg: 8, xxl: 6 },
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      placeholder: ['开始时间', '结束时间'],
      showTime: { format: 'HH:mm:ss' },
    },
    defaultValue:[dayjs(new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 7 )).format('YYYY-MM-DD'),dayjs(new Date()).format('YYYY-MM-DD')]
  },
  {
    field: 'status',
    label: '操作方式',
    labelWidth: 80,
    component: 'Select',
    componentProps: {
      options: [
        { label: '查询', value: 'search' },
        { label: '修改', value: 'update' },
        { label: '删除', value: 'delete' },
        { label: '导入', value: 'import' },
        { label: '导出', value: 'export' },
      ],
    },
    colProps: { xs: 24, xl: 12, lg: 8, xxl: 6 },
  },
  {
    field: 'status',
    label: '操作状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '成功', value: '1' },
        { label: '失败', value: '0' },
      ],
    },
    colProps: { xs: 24, xl: 12, lg: 8, xxl: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'roleName',
    label: '角色名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'roleValue',
    label: '角色值',
    required: true,
    component: 'Input',
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: '0',
    componentProps: {
      options: [
        { label: '启用', value: '1' },
        { label: '停用', value: '0' },
      ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: ' ',
    field: 'menu',
    slot: 'menu',
  },
];
